PROGECT_PATH = E:\my_google_code\0.11_to_rtt\1
DEL = del
#DEL = rm -f
DEVICE = -mcpu=arm920t
TextBase = 0x30000000
TARGET = hello

PREFIX = arm-none-eabi-
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc
AR = $(PREFIX)ar
LINK = $(PREFIX)gcc
SIZE = $(PREFIX)size
OBJDUMP = $(PREFIX)objdump
OBJCPY = $(PREFIX)objcopy

LPATH  = -I./ -I$(PROGECT_PATH) -I$(PROGECT_PATH)/include/
AFLAGS = -x assembler-with-cpp -DTEXT_BASE=$(TextBase)
CFLAGS = -c $(DEVICE) -g -O0 -gdwarf-2
LINKFLAGS = $(DEVICE) -Wl,--gc-sections,-Map=a.map,-cref,-u,_start -T mini2440_ram.ld -Ttext $(TextBase)

# every time we just build changed file, so vw have to list the changed file list here
all:
	$(AS) $(AFLAGS) $(CFLAGS) $(LPATH) -o start.o start.s
	$(CC) $(CFLAGS) $(LPATH) -o init/main.o init/main.c
	
	$(LINK) $(LINKFLAGS) -o $(TARGET).axf *.o ./init/*.o ./fs/*.o ./mm/*.o ./kernel/*.o
	$(OBJCPY) -O binary $(TARGET).axf $(TARGET).bin
	$(SIZE) $(TARGET).axf

alll:
	$(AS) $(AFLAGS) $(CFLAGS) $(LPATH) -o start.o start.s
	$(CC) $(CFLAGS) $(LPATH) -o kernel/traps.o  kernel/traps.c
	
	$(CC) $(CFLAGS) $(LPATH) -o fs/super.o  fs/super.c
	$(CC) $(CFLAGS) $(LPATH) -o mm/memory.o  mm/memory.c
	
	$(CC) $(CFLAGS) $(LPATH) -o lcd_t35.o lcd_t35.c
	$(CC) $(CFLAGS) $(LPATH) -o uart0.o uart0.c
	$(CC) $(CFLAGS) $(LPATH) -o my_printf.o my_printf.c
	
	$(CC) $(CFLAGS) $(LPATH) -o init/main.o init/main.c
	
	$(LINK) $(LINKFLAGS) -o $(TARGET).axf *.o ./init/*.o ./fs/*.o ./mm/*.o ./kernel/*.o
	$(OBJCPY) -O binary $(TARGET).axf $(TARGET).bin
	$(SIZE) $(TARGET).axf

clean:
	-$(DEL)  *.o
	
	-$(DEL)  init\*.o
	-$(DEL)  fs\*.o
	-$(DEL)  mm\*.o
	-$(DEL)  kernel\*.o
	
	-$(DEL)  *.axf
	-$(DEL)  *.bin
	-$(DEL)  *.map
#-$(DEL)  *~

.PHONY: clean

